package com.ruoyi.project.tugboat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.project.tugboat.service.ICTugboatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.tugboat.domain.CTugboat;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 拖轮数据Controller
 * 
 * @author ruoyi
 * @date 2023-12-14
 */
@RestController
@RequestMapping("/system/tugboat")
public class CTugboatController extends BaseController
{
    @Autowired
    private ICTugboatService cTugboatService;

    /**
     * 查询拖轮数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:list')")
    @GetMapping("/list")
    public TableDataInfo list(CTugboat cTugboat)
    {
        startPage();
        List<CTugboat> list = cTugboatService.selectCTugboatList(cTugboat);
        return getDataTable(list);
    }

    /**
     * 导出拖轮数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:export')")
    @Log(title = "拖轮数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CTugboat cTugboat)
    {
        List<CTugboat> list = cTugboatService.selectCTugboatList(cTugboat);
        ExcelUtil<CTugboat> util = new ExcelUtil<CTugboat>(CTugboat.class);
        util.exportExcel(response, list, "拖轮数据数据");
    }

    /**
     * 获取拖轮数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:query')")
    @GetMapping(value = "/{tugboatId}")
    public AjaxResult getInfo(@PathVariable("tugboatId") Long tugboatId)
    {
        return success(cTugboatService.selectCTugboatByTugboatId(tugboatId));
    }

    /**
     * 新增拖轮数据
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:add')")
    @Log(title = "拖轮数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CTugboat cTugboat)
    {
        return toAjax(cTugboatService.insertCTugboat(cTugboat));
    }

    /**
     * 修改拖轮数据
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:edit')")
    @Log(title = "拖轮数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CTugboat cTugboat)
    {
        return toAjax(cTugboatService.updateCTugboat(cTugboat));
    }

    /**
     * 删除拖轮数据
     */
    @PreAuthorize("@ss.hasPermi('system:tugboat:remove')")
    @Log(title = "拖轮数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tugboatIds}")
    public AjaxResult remove(@PathVariable Long[] tugboatIds)
    {
        return toAjax(cTugboatService.deleteCTugboatByTugboatIds(tugboatIds));
    }
}
